package com.cat.dataStructure02;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/string-without-aaa-or-bbb/
 * @create 2025/10/29 20:23
 * @since JDK17
 */

public class Solution81 {
    public String strWithout3a3b(int a, int b) {
        StringBuffer ans = new StringBuffer();
        while (a > b && b > 0) {
            ans.append("aab");
            a -= 2;
            b--;
        }
        while (a < b && a > 0) {
            ans.append("bba");
            a--;
            b -= 2;
        }
        while (a == b && a != 0) {
            ans.append("ab");
            a--;
            b--;
        }
        ans.append("a".repeat(a));
        ans.append("b".repeat(b));
        return ans.toString();
    }
}

